﻿chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => {
    let url = tabs[0].url;
    // use `url` here inside the callback because it's asynchronous!
	if (url.startsWith("https://arxiv.org/")) {
		if (url.endsWith('.pdf')) {
			var pdf = url.split("/");
			pdf = pdf.pop();
			pdf = pdf.slice(0, -4);
			new_url = "https://arxiv.org/abs/" + pdf;
			window.open(new_url, "_blank");
		}
	}
});